// 引入 react 依赖
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Text, View, Image, TouchableOpacity, ImageBackground, ScrollView, InteractionManager } from 'react-native';

// 引入第三方依赖
import _ from 'lodash';
import pureRender from 'pure-render-decorator';
import { Actions } from 'react-native-router-flux';
import Icon from 'react-native-vector-icons/Ionicons';

// antd 按需加载
import { Tabs, Toast, Portal } from '@ant-design/react-native';

// 引入 处理数据 所需文件
import { cardSave } from '../../module/module.js'

// 引入样式
import Style from './style/style.js';

// 引入公用组件
import { Status, NavBar, CacheImage, RnFlatList, CardForm } from '../../components/index.js'

// 引入专用组件
import { } from './components'

// 引入工具包
import { } from '../../util/images.js';
import { press, size, ScreenWidth, borderBottom, pathHead, defaultDataList, onEndReached, onRefresh, concatDataList, defaultPage } from '../../util/utils.js'

class PostCard extends Component {

  constructor(props) {
    super(props)
    this.state = {
      refreshing: false,
      loading: false,
    }
  }

  componentDidMount() {
    InteractionManager.runAfterInteractions(() => {
      // ...耗时较长的同步的任务...

    });
  }
  
  cardSave(option){
    console.log(option)
    this.loading = Toast.loading('发布中', 0)
    cardSave(option).then(res=>{
      console.log(res)
      Actions.pop()
    }).finally(()=>{
      Portal.remove(this.loading)
    })
  }

  render() {
    const { refreshing, dataList } = this.state
    return (
      <View style={Style.container}>
        <Status />
        <NavBar
          title="发布帖子"
          back={true}
        />
        <CardForm onPress={(option) => this.cardSave(option)}>发布帖子</CardForm>
      </View >
    );
  }
}


export default connect(({ user }) => ({
  user,
}))(pureRender(PostCard))
